package cn.quevo.cube.provide.define.validate;

import cn.quevo.cube.provide.define.entity.dto.CubeColumnDto;
import cn.quevo.cube.provide.define.enums.ColumnTypeCode;

/**
 * 字段类型验证工厂类
 *
 * @author July july_sky@foxmail.com
 * @version 1.0
 * @date 2018/12/14 5:42 PM
 * @Copyright 湘豫（北京）科技有限公司版权所有.All Rights Reserved.
 */
public class ColumnTypeValidateFactory {

    public static void validate(CubeColumnDto cubeColumnDto) {
        ColumnTypeCode columnTypeCode = null;
        try {
            columnTypeCode = ColumnTypeCode.valueOf(cubeColumnDto.getTypeCode().toUpperCase());
        } catch (Exception e) {
            columnTypeCode = ColumnTypeCode.valueOf(cubeColumnDto.getColumnTypeCd().toUpperCase());
        }
        columnTypeCode.getValidateClass().validate(cubeColumnDto);
    }
}
